<template>
	<view>
		<view class="record">
			<view class="record_box" v-for="(item,index) in records" :key="index" @click="toDetail(item)">
				<view class="box">
					<view class="time">{{item.orderTime}}</view>
					<view class="company_detail">
						<image :src="item.coverImg" class="tupian"></image>
						<view class="price">
							<view>
								<text class="cu" v-if="item.activityFlag == 1">促</text>
								<text class="company_name">{{item.serviceTitle}}</text>
							</view>
							<view class="pri">￥{{item.price}}</view>
						</view>
					</view>
					<view class="progress">
						<view class="tip">
							<view class="cirle"></view>
							<text class="pro">{{item.schedule}}</text>
						</view>
						<view class="look">
							<view>查看详情</view>
							<image src="../../static/first/right.png"></image>
						</view>
					</view>
				</view>
			</view>
			<!-- 进度 -->
		</view>
		<view class="uni-loadmore" v-if="showLoadMore">{{loadMoreText}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				records: [],
				pageNo: 1,
				loadMoreText: '加载中',
				showLoadMore: false,
			}
		},
		onReachBottom() {
			let that = this
			let userInfo = uni.getStorageSync('userInfo')
			that.showLoadMore = true;
			setTimeout(() => {
				that.getMyServiceRecords(userInfo.id);
			}, 300);
		},
		onLoad() {
			let userInfo = uni.getStorageSync('userInfo')
			this.getMyServiceRecords(userInfo.id)
		},
		methods: {
			//获取我的服务记录
			getMyServiceRecords(userId) {
				uni.request({
					url: this.$serverUrl + 'ftOrder/getOrdersByUserId',
					data: {
						"pageNo": this.pageNo,
						"pageSize": 10,
						"userId": userId
					},
					method: 'POST',
					success: (res) => {
						let data = res.data
						if (data.length == 0) {
							this.loadMoreText = '没有更多了'
						} else {
							this.pageNo += 1
							this.records = this.records.concat(data)
						}
					},
					fail: (e) => {
						uni.showToast({
							title: '服务记录获取失败',
							icon: 'none'
						})
					}
				})
			},
			//跳转到记录详情里
			toDetail(item) {
				uni.navigateTo({
					url: '/pages/mine/recordDet?op=' + encodeURIComponent(JSON.stringify(item))
				})
			}
		}
	}
</script>

<style>
	.uni-loadmore {
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		padding-bottom: 30rpx;
	}

	page {
		background-color: #FAFAFA;
	}

	.record_box {
		margin: 18upx 36upx;
		background-color: #FFFFFF;
	}

	.box {
		margin: 0 36upx;
	}

	.time {
		height: 106upx;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		align-items: center;
		color: #333333;
		font-size: 26upx;
	}

	.company_detail {
		height: 194upx;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		align-items: center;
	}

	.tupian {
		width: 212upx;
		height: 142upx;
		border-radius: 10upx;
		background-color: #666666;
	}

	.price {
		margin-left: 26upx;

	}

	.cu {
		width: 44upx;
		height: 44upx;
		background-color: #F87935;
		border-radius: 4upx;
		display: inline-block;
		font-size: 26upx;
		line-height: 44upx;
		text-align: center;
		color: #FFFFFF;
	}

	.company_name {
		font-size: 34upx;
		letter-spacing: 3upx;
		margin-left: 10upx;
	}

	.pri {
		font-size: 26upx;
		color: #DE3232;
		font-weight: bold;
		margin-top: 28upx;
	}

	.progress {
		height: 88upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.tip {
		display: flex;
		align-items: center;
	}

	.cirle {
		width: 14upx;
		height: 14upx;
		border-radius: 50%;
		background-color: #00B2CA;
	}

	.pro {
		margin-left: 20upx;
		font-size: 30upx;
		color: #666666;
	}

	.look {
		display: flex;
		align-items: center;
	}

	.look image {
		width: 28upx;
		height: 28upx;
		margin-left: 20upx;
	}

	.look view {
		color: #00B2CA;
		font-size: 26upx;
	}
</style>
